import java.util.HashSet;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mirac
 * Date: 2025-09-06
 * Time: 23:56
 */
public class Solution {

    public static int[] CheckForPlagiarism(int[] arr) {
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < arr.length; i++) {
            set.add(arr[i]);
        }
        Integer[] ret = set.toArray(new Integer[0]);
        int[] ans = new int[ret.length];
        for (int i = 0; i < ret.length; i++) {
            ans[i] = ret[i];
        }
        return ans;
    }

    public static int find(int[] arr) {
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < arr.length; i++) {
            if (!set.contains(arr[i])) {
                set.add(arr[i]);
            }else {
                return arr[i];
            }
        }
        //无重复的就返回-1
        return -1;
    }
}
